package com.terrynoya.fight.stateMachine.triggers
{
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.emuns.Axis;
	import com.terrynoya.fight.evaluation.Node;
	import com.terrynoya.fight.evaluation.ParseState;

	public class Vel
	{
		public function Vel()
		{
		}
		
		public static function eval(data:Object,node:Node):*
		{
			var chara:Character = Character(data);
			if(chara == null)
			{
				return 0;
			}
			var axis:int = node.arguments[0];
			switch(axis)
			{
				case Axis.X:
				{
					return chara.velocity.x;
					break;
				}
				case Axis.Y:
				{
					return chara.velocity.y;	
					break;
				}
			}
		}
		
		public static function parse(state:ParseState):Node
		{
			var val:String = state.currentUnknown;
			var axis:int = Axis.None;
			switch(val)
			{
				case "x":
				{
					axis = Axis.X;
					break;
				}
				case "y":
				{
					axis = Axis.Y;
					break;
				}
			}
			if(axis == Axis.None)
			{
				return null;
			}
			state.tokenIndex ++;
			state.baseNode.arguments.push(axis);
			return state.baseNode;
		}
	}
}